<%--
  Created by IntelliJ IDEA.
  User: 31036
  Date: 2025/3/23
  Time: 20:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>充值列表</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="../../static/layui/css/layui.css" rel="stylesheet">
    <script src="../../static/js/jquery-1.8.3.js"></script>
</head>
<body>
您的余额为：
<input type="text" value="${user.userMoney}"><br>
<form class="layui-form layui-row layui-col-space16">
    <div class="layui-col-md4">
        <div class="layui-input-wrap">
            <div class="layui-input-prefix">
                <i class="layui-icon layui-icon-username"></i>
            </div>
            <input type="text" name="A" value="" placeholder="Field A" class="layui-input" lay-affix="clear">
        </div>
    </div>
    <div class="layui-col-md4">
        <div class="layui-input-wrap">
            <input type="text" name="B" placeholder="Field B" lay-affix="clear" class="layui-input">
        </div>
    </div>
    <div class="layui-col-md4">
        <div class="layui-input-wrap">
            <div class="layui-input-prefix">
                <i class="layui-icon layui-icon-date"></i>
            </div>
            <input type="text" name="C" readonly placeholder="Field C" class="layui-input demo-table-search-date">
        </div>
    </div>
    <div class="layui-btn-container layui-col-xs12">
        <button class="layui-btn" lay-submit lay-filter="demo-table-search">Search</button>
        <button type="reset" class="layui-btn layui-btn-primary">Clear</button>
    </div>
</form>

<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">

        {{#  if(${user.roleListStr.contains(",3,")} ){ }}
            <button class="layui-btn layui-btn-sm" lay-event="chongzhi">充值</button>
        {{#  } }}



    </div>
</script>
<div class="layui-btn-container">
    <button type="button" class="layui-btn demo-class-accept" lay-options="{accept: 'file'}">
        <i class="layui-icon layui-icon-upload"></i>
        导入
    </button>
</div>
<table class="layui-hide" id="ID-table-demo-search"></table>

<!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
<script src="../../static/layui/layui.js"></script>
<script>
    layui.use(function(){
        var table = layui.table;
        var form = layui.form;
        var laydate = layui.laydate;
        var upload = layui.upload;
        // 创建表格实例
        table.render({
            limit:3,
            toolbar: '#toolbarDemo',
            elem: '#ID-table-demo-search',
            url: '/recharge/getRechargeList', // 此处为静态模拟数据，实际使用时需换成真实接口
            cols: [[
                {type: 'checkbox', title: '😊', fixed: true}, // 单选框
                {field:'rechargeId', title: 'id', width:80, sort: true, fixed: true},
                {field:'userId', title: '用户id', width:100},
                {field:'rechargeMoney', title: '充值金额', width:100},
                {field:'parkId', title: '停车场id', width:80},
                {field:'rechargeTime', title: '充值时间', width:100},
                {field:'rechargeState', title: '充值状态', width:100},
                {field:'updTime', title: '修改时间', width:100},
                {field:'rechargeKouling', title: '充值口令', width:160},
            ]],
            parseData: function(res){ // res 即为原始返回的数据
                return {
                    "code": 0, // 解析接口状态
                    "msg": res.message, // 解析提示文本
                    "count": res.total, // 解析数据长度
                    "data": res.list // 解析数据列表
                };
            },
            request: {
                pageName: 'pageNum', // 页码的参数名称，默认：page
                limitName: 'pageSize' // 每页数据条数的参数名，默认：limit
            },
            page: true,
            height: 310
        });





        // 渲染
        upload.render({
            elem: '.demo-class-accept', // 绑定多个元素
            url: '/recharge/daoru', // 此处配置你自己的上传接口即可
            accept: 'file', // 普通文件
            done: function(res){
                if (res.css===200){
                    layer.msg('导入成功');
                    location.reload()
                }
                if (res.code===100){
                    console.log(res.msg);
                }

            }
        });








        // 工具栏事件
        table.on('toolbar(ID-table-demo-search)', function(obj){
            var id = obj.config.id;
            var checkStatus = table.checkStatus(id);
            var othis = lay(this);
            switch(obj.event){
                case 'chongzhi':
                    location.href="../recharge/add.jsp"
                    break;
            };
        });
        // 日期
        laydate.render({
            elem: '.demo-table-search-date'
        });
        // 搜索提交
        form.on('submit(demo-table-search)', function(data){
            var field = data.field; // 获得表单字段
            // 执行搜索重载
            table.reload('ID-table-demo-search', {
                page: {
                    curr: 1 // 重新从第 1 页开始
                },
                where: field // 搜索的字段
            });
            layer.msg('搜索成功<br>此处为静态模拟数据，实际使用时换成真实接口即可');
            return false; // 阻止默认 form 跳转
        });
    });
</script>
</body>
</html>
